﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace ArticleManagementSystem
{
    public class DbHelp
    {
        public static string constr = "server=.;database=CMS;uid=sa;pwd=123456";

        public static DataTable dataTable(string sql) {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql,constr);
            DataTable table = new DataTable();
            sqlDataAdapter.Fill(table);
            return table;
        }

        public static int change(string sql) {
            SqlConnection sqlConnection = new SqlConnection(constr);
            SqlCommand sqlCommand = new SqlCommand(sql,sqlConnection);
            sqlConnection.Open();
            var i = sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            return i;
        }
    }
}